
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        ul{
            display: flex;
        }
        li{
            width: 100px;
            height: 100px;
            list-style: none;
            margin-left: 20px;
        }
        body{
            background-image: url(./img/1.jpg);
        }
    </style>
</head>
<body>
    <ul>
        <li><img src="img/1.jpg" alt=""></li>
        <li><img src="img/2.jpg" alt=""></li>
        <li><img src="img/3.jpg" alt=""></li>
    </ul>
</body>
<script>
    var imgs = document.querySelectorAll('img')
    var body = document.querySelector('body')

    for (let i = 0; i < imgs.length; i++) {
        imgs[i].onclick = function(){
            var imgss = this.src
            body.style = 'background-image:url('+imgss+')'
        }
    }
</script>
</html>